import { List, Modal, Grid, DatePickerView, Toast } from 'antd-mobile';
import { Button, Divider, Alert } from 'antd';
import moment from 'moment';
import React, { useState } from 'react';
import { connect, history, useRequest } from 'umi';
import { ArrowRightOutlined } from '@ant-design/icons';
import BackIcon from '@/components/BackIcon';
import { useEffect } from 'react';
import { putFetch } from '@/utils/doFetch';
import { useMemo } from 'react';
import PublicList from '@/components/PublicList';
import { payment_order, payment } from '@/services/factory';
import styles from './index.less';

let Header = connect(({ global, loading }) => ({
  global,
  loading,
}))(({ global: { userinfo, companies } }) => {
  useEffect(() => {
    payment({ company_id: companies?.id }).then((res) => {
      console.log(res?.data);
    });
  }, []);

  return (
    <div className={styles.adds}>
      <div
        style={{ fontSize: 16, textAlign: 'center', maxWidth: 210 }}
        className="oneline"
      >
        {companies?.name}
      </div>
      <div
        style={{ width: 88 }}
        onClick={() => {
          history.push('/payment');
        }}
      >
        付款方式 <ArrowRightOutlined></ArrowRightOutlined>
      </div>
    </div>
  );
});

let Resource = connect(({ global, loading }) => ({
  global,
  loading,
}))(({ global: { userinfo, companies } }) => {
  return (
    <div style={{ height: '100%' }}>
      <BackIcon></BackIcon>
      <PublicList
        Header={Header}
        post={payment_order}
        type="payment_order"
        params={{ company_id: companies?.id }}
      ></PublicList>
    </div>
  );
});

export default connect(({ global, loading }) => ({
  global,
  loading,
}))(Resource);
